// 导入路由
import { Router, Route, Redirect } from 'react-router-dom'
//导入的组件后面的index.js可以省略
import { history } from './utils/history'
import './App.css'
import Login from './pages/Login'
import Layout from './pages/Layout'
import { AuthRoute } from './components/AuthRoute'
const App = () => {
  return (
    // 让路由使用自定义的history，将各个页面关联起来进行跳转
    <Router history={history}>
      <div className="app">
        {/* 在默认路由情况下设置重定向 */}
        <Route
          exact
          path="/"
          render={() => {
            return <Redirect to="/home" />
          }}
        ></Route>
        <AuthRoute path="/home" component={Layout}></AuthRoute>
        <Route path="/login" component={Login}></Route>
      </div>
    </Router>
  )
}
export default App
